package com.kly.cashmall.module.order.presenter;


import com.kly.cashmall.bean.RepayDetailsBean;
import com.kly.cashmall.framework.mvp.BaseViewPresenter;
import com.kly.cashmall.services.Network;
import com.kly.cashmall.services.Params;
import com.kly.cashmall.widget.Loading.LoadingDialog;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class LoanRepayDetailsPresenter extends BaseViewPresenter<LoanRepayDetailsViewer> {

    public LoanRepayDetailsPresenter(LoanRepayDetailsViewer viewer) {
        super(viewer);
    }

    @Override
    public void willDestroy() {

    }
    public void getOrderRepayDetail(String billNo){
        LoadingDialog.showLoading(getActivity());
        Params params = new Params();
        params.put("billNo", billNo);
        rxManager.add(Network.getApi().getOrderRepayDetail(params.buildPostBody()).subscribeOn(Schedulers.io()).observeOn
                (AndroidSchedulers.mainThread()).subscribe(new Consumer<RepayDetailsBean>() {
            @Override
            public void accept(RepayDetailsBean bean) throws Exception {
                LoadingDialog.dismissLoading();
                if (getViewer() != null) {
                    getViewer().getOrderRepayDetailSuccess(bean);
                }
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LoadingDialog.dismissLoading();
            }
        }));
    }
}